<template>
	<view class="content">
		<uni-list class="list">
			<uni-list-item title="个人资料" clickable @click="navigateTo('personalInfo')"></uni-list-item>
			<uni-list-item title="账号安全" clickable @click="navigateTo('accountSecurity')"></uni-list-item>
			<uni-list-item title="个性化" clickable @click="navigateTo('minorMode')"></uni-list-item>
			<uni-list-item title="收货地址" clickable @click="navigateTo('careMode')"></uni-list-item>
			<uni-list-item title="意见反馈" clickable @click="navigateTo('notifications')"></uni-list-item>
			<uni-list-item title="关于我们" clickable @click="navigateTo('general')"></uni-list-item>
		</uni-list>
		<view class="set" @click="showSharePanel">
			<text>退出登录</text>
		</view>
		<!-- 遮罩层 -->
		<view v-if="isShareVisible" class="mask" @click="hideSharePanel"></view>
		<!-- 分享面板 -->
		<view v-if="isShareVisible" :animation="shareAnimation" class="share-panel">
			<view class="share-content" @click.stop>
				<view class="item" @click="handleLogout">退出登录</view>
				<view class="item" @click="hideSharePanel">取消</view>
			</view>
		</view>
	</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				isShareVisible: false,
				shareAnimation: null, // 初始化动画为空
				pagePaths: {
					personalInfo: '/pages/set/personalInfo/personalInfo',
					accountSecurity: '/pages/set/accountSecurity/accountSecurity',
					minorMode: '/pages/set/minorMode/minorMode',
					careMode: '/pages/set/careMode/careMode',
					notifications: '/pages/set/notifications/notifications',
					general: '/pages/set/general/general'
				}
			};
		},
		methods: {
			navigateTo(pageKey) {
				const url = this.pagePaths[pageKey];

				if (url) {
					uni.navigateTo({
						url: url
					});
				} else {
					console.warn(`未找到页面路径: ${pageKey}`);
				}
			},
			showSharePanel() {
				this.isShareVisible = true;
				this.shareAnimation = uni.createAnimation({
					duration: 300,
					timingFunction: 'ease'
				});

				// 动画开始时先设置初始状态
				this.shareAnimation.bottom('-100%').step();
				this.$nextTick(() => {
					// 设置最终状态，动画会自动播放
					this.shareAnimation.bottom(0).step();
					this.shareAnimation = this.shareAnimation.export();
				});
			},
			hideSharePanel() {
				const animation = uni.createAnimation({
					duration: 300,
					timingFunction: 'ease'
				});

				animation.bottom('-100%').step(); // 收回到底部

				this.shareAnimation = animation.export();

				setTimeout(() => {
					this.isShareVisible = false;
				}, 300); // 动画结束后隐藏
			},
			handleLogout() {
				// 实现你的退出登录逻辑
				console.log('用户选择了退出登录');
				// 这里可以添加登出操作，如清除本地存储、跳转到登录页等
			}
		}

	}
</script>

<style lang="scss">
	.content {
		padding: 8px;
	}

	.set {
		background-color: #fff;
		height: 50px;
		display: flex;
		align-items: center;
		justify-content: center;
		color: red;
		font-size: 15px;
	}

	/* 添加样式以美化退出登录和取消选项 */
	.share-panel {
		position: fixed;
		bottom: 0;
		width: 100%;
		background-color: white;
		z-index: 1000;
	}

	.share-content .item {
		padding: 20rpx;
		text-align: center;
		border-bottom: 1px solid #eee;
	}

	.share-content .item:last-child {
		border-bottom: none;
	}
</style>